<?php
/**
 *  
 * @file   Api.php  
 * @date   2019-6-28
 * @author zhu  
 */
namespace app\api\controller\v1;
use app\BaseController;

class Api extends BaseController{
    /**
     * 获取url
     */
    protected function initialize() {
        $this->url = config('api.url');

    }

    public function test()
    {
        echo '123456';
        $url = $this->url;
        dump($url);
    }

    /**
     * 获取token值
     * static 静态方法无法 使用获取初始化的变量赋值  类必须继承BaseController
     * @return type
     */
    public static function getToken(){
        $url = config('api.url');
        $data = array(
            "_app_name"=>"com.SAKX.FoodSafetyAdmin",
            "_secret"=>"WZvpokjLLRTO44gj",
            "g"=>"Api2.0",
            "m"=>"Public",
            "c"=>"postToken"
        );
        $output = curl_post($url, $data);
        return $output;
       
    }
    
    /**
     * 获取新闻栏目列表
     * @return type
     */
    public function getCategoryList()
    {
        $pid = input('post.pid', 0, 'intval');
        $pageIndex = input('post.page', 1, 'intval');
        $returnData = Api::getToken();
        $return = (json_decode($returnData,true));
        $url = $this->url;
        $data = array(
            "_app_name"=>"com.SAKX.FoodSafetyAdmin",
            "g"=>"Api2.0",
            "m"=>"Content",
            "c"=>"public_getCategoryList",
            "_token"=>$return['content']['access_token'],
            "pid"=>$pid,
            "page_index" => $pageIndex,
            
        );
        $output = curl_post($url, $data);
        return $output;
    }

    /**
     * 获取新闻列表
     */
    public function getContentList()
    {
        $categoryId = input('post.categoryId', 0, 'intval');
        $pageIndex = input('post.page', 0, 'intval');
        $listRow = input('post.limit', 0, 'intval');
        $returnData = Api::getToken();
        $return = (json_decode($returnData,true));
        $url = $this->url;
        $data = array(
            "_app_name"=>"com.SAKX.FoodSafetyAdmin",
            "g"=>"Api2.0",
            "m"=>"Content",
            "c"=>"public_getContentList",
            "_token" => $return['content']['access_token'],
            "category_id"=> $categoryId,
            "page_index" => $pageIndex,
            "list_row" => $listRow
            
        );
        $output = curl_post($url, $data);
        $result = json_decode($output, true);
        $result = ['code'=>0,'msg'=>'获取成功!','data'=>$result['content']['content_list'],'count'=>$result['content']['page']['totalRows']];
        return $result;
    }

    /**
     * 获取新闻明细
     * @return type
     */
    public function getContentInfo()
    {
        $id = input('get.id', 0, 'intval');
        $returnData = Api::getToken();
        $return = (json_decode($returnData,true));
        $url = $this->url;
        $data = array(
            "_app_name"=>"com.SAKX.FoodSafetyAdmin",
            "g"=>"Api2.0",
            "m"=>"Content",
            "c"=>"public_getContentInfo",
            "_token" => $return['content']['access_token'],
            "id"=> $id,   
        );
        $output = curl_post($url, $data);
        return $output;
    }

    /**
     * 注册发送验证码
     * @return type
     */
    public static function sendCode()
    {
        $mobile = input("get.mobile");
        $returnData = Api::getToken();
        $return = (json_decode($returnData,true));
        $url = config('wx.url');
        $data = array(
            "_app_name"=>"com.SAKX.FoodSafetyAdmin",
            "_Version"=>"2.0",
            "g"=>"ApiElearning",
            "m"=>"Public",
            "c"=>"getRegVerifyCode",
            "_token"=>$return['content']['access_token'],
            "mobile"=>$mobile
            
        );
        $output = curl_post($url, $data);
        return $output;
    }
    
    /**
     * 用户注册
     * @return type
     */
    public function register()
    {
        $phone = input("post.phone");
        $password = input("post.password");
        $code = input("post.code");
        $returnData = Api::getToken();
        $return = (json_decode($returnData,true));
        $url = config('wx.url');
        $data = array(
            "_app_name" => "com.SAKX.FoodSafetyAdmin",
            "_Version" => "2.0",
            "g" => "ApiElearning",
            "m" => "Public",
            "c" => "real_register",
            "_token" => $return['content']['access_token'],
            "mobile" => $phone,
            "password" => $password,
            "verify_code" => $code,
            
        );
        $output = curl_post($url, $data);
        return $output;
    }
    /**
     * 用户登录
     * @return type
     */
    public function login()
    {
        $userName = input("post.phone");
        $password = input("post.password");
       
        $returnData = Api::getToken();
        $return = (json_decode($returnData,true));
        $url = $this->url;
        $data = array(
            "_app_name" => "com.SAKX.FoodSafetyAdmin",
            "_Version" => "2.0",
            "g" => "ApiElearning",
            "m" => "Public",
            "c" => "login",
            "_token" => $return['content']['access_token'],
            "user_name" => $userName,
            "password" => $password,
        );
        $data  = json_encode($data);
        $headerArray = array("Content-type:application/json;charset='utf-8'","Accept:application/json");
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,FALSE);
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
        curl_setopt($curl,CURLOPT_HTTPHEADER,$headerArray);
        curl_setopt($curl, CURLOPT_HEADER, 1);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        $output = curl_exec($curl);
        curl_close($curl);
        list($header, $body) = explode("\r\n\r\n", $output, 2);
        preg_match("/ZJ-LVEI3DRhYauth\=(.*?)\;/", $header, $matches);
        if($matches){
            // 设置Cookie 有效期为 604800
            cookie('Set-Cookie',$matches['0'],604800);
        }
        
        //return json_decode($body, true);
        
        return $body;
        
    }
    
    /**
     * 重置密码发送验证码
     * @return type
     */
    public function resetPwdSendCode()
    {
        $mobile = input("get.mobile");
        $returnData = Api::getToken();
        $return = (json_decode($returnData,true));
        $url = config('wx.url');
        $data = array(
	        "_app_name"=>"com.SAKX.FoodSafetyAdmin",
            "_Version"=>"2.0",
	        "g"=>"ApiElearning",
            "m"=>"Public",
            "c"=>"forgetPasswordSendVerify",
            "_token"=>$return['content']['access_token'],
            "identifier"=>$mobile,
            "method"=>"mobile"
            
        );
        $output = curl_post($url, $data);
        return $output;
    }
    /**
     * 用户密码重置
     * @return type
     */
    public function resetPassword()
    {
        $phone = input("post.phone");
        $password = input("post.password");
        $code = input("post.code");
        $re_password = input("post.confirm_password");
       
        $returnData = Api::getToken();
        $return = (json_decode($returnData,true));
        $url = config('wx.url');
        $data = array(
            "_app_name" => "com.SAKX.FoodSafetyAdmin",
            "_Version" => "2.0",
            "g" => "ApiElearning",
            "m" => "Public",
            "c" => "forgetPasswordResetPassword",
            "_token" => $return['content']['access_token'],
            "identifier" => $phone,
            "verify_code" => $code,
            "password" => $password,
            "re_password" => $re_password,
        );
        $output = curl_post($url, $data);
        return $output;
    }
    /**
     * 上传图片
     * @return type
     */
    public function uploadPictrue()
    {
        $base64_image = input("post.img");
        $returnData = Api::getToken();
        $return = (json_decode($returnData,true));
        $url = config('wx.url');
        $data = array(
            "_app_name" => "com.SAKX.FoodSafetyAdmin",
            "_Version" => "2.0",
            "g" => "ApiElearning",
            "m" => "Public",
            "c" => "base64_image_upload",
            "_token" => $return['content']['access_token'],
            "base64_image_content" => "data:image/png;base64,".$base64_image,
        );
        $data  = json_encode($data);    
        $headerArray =array("Content-type:application/json;charset='utf-8'","Accept:application/json");
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,FALSE);
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
        curl_setopt($curl,CURLOPT_HTTPHEADER,$headerArray);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        $output = curl_exec($curl);
        curl_close($curl);
        return json_decode($output);
    }
    
    /**
     * 实名认证列表
     * @return type
     */
    public function certification()
    {
        $phone = input("psot.phone");
        $name = input("post.name");
        $idcard = input("post.idcardnumber");
        $attachinfo = input("post.attachinfo");
        $certificatephotosinfo = input("post.certificatephotosinfo");
        $returnData = Api::getToken();
        $return = (json_decode($returnData,true));
        $url = config('wx.url');
        $data = array(
            "_app_name" => "com.SAKX.FoodSafetyAdmin",
            "_Version" => "2.0",
            "g" => "ApiElearning",
            "m" => "User",
            "c" => "editMemberVerified",
            "_token" => $return['content']['access_token'],
            "category_id" => 1,
            "phone" => $phone,
            "realname" => $name,
            "idcard" => $idcard,
            "attach_info" => $attachinfo,
            "certificate_photos_info" => $certificatephotosinfo,
        );
        
        $data  = json_encode($data);    
        $headerArray = array("Content-type:application/json;charset='utf-8'","Accept:application/json");
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,FALSE);
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
        curl_setopt($curl,CURLOPT_HTTPHEADER,$headerArray);
        curl_setopt ($curl, CURLOPT_COOKIE , cookie('Set-Cookie'));
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        $output = curl_exec($curl);
        curl_close($curl);
        return json_decode($output);
    }
    
    /**
     * 首页在线考试
     * @return type
     */
    public function online()
    {
        $returnData = Api::getToken();
        $return = (json_decode($returnData,true));
        $url = config('wx.url');
        $data = array(
            "_app_name" => "com.SAKX.FoodSafetyAdmin",
            "_Version" => "2.0",
            "g" => "ApiElearning",
            "m" => "Exam",
            "c" => "public_getExamList",
            "_token" => $return['content']['access_token'],
            // "page_index" => "1",
            // "list_row" => "4"
            
        );
        $output = curl_post($url, $data);
        return $output;
    }
    
    /**
     * 在线考试列表信息
     * @return type
     */
    public function examList()
    {
        $returnData = Api::getToken();
        $return = (json_decode($returnData,true));
        $url = config('wx.url');
        $data = array(
            "_app_name" => "com.SAKX.FoodSafetyAdmin",
            "_Version" => "2.0",
            "g" => "ApiElearning",
            "m" => "Exam",
            "c" => "public_getExamList",
            "_token" => $return['content']['access_token'],     
        );
        
        $data  = json_encode($data);    
        $headerArray =array("Content-type:application/json;charset='utf-8'","Accept:application/json");
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,FALSE);
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
        curl_setopt($curl,CURLOPT_HTTPHEADER,$headerArray);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        $output = curl_exec($curl);
        curl_close($curl);
        return $output;
    }
    
    /**
     * 开始考试
     * @return type
     */
    public function startExam()
    {
        $type_id = input("get.type_id");
        $phone = input("get.phone");
        $returnData = Api::getToken();
        $return = (json_decode($returnData,true));
        $url = $this->url;
        $data = array(
            "_app_name" => "com.SAKX.FoodSafetyAdmin",
            "_Version" => "2.0",
            "g" => "ApiElearning",
            "m" => "Exam",
            "c" => "startExam",
            "_token" => $return['content']['access_token'],
            "type_id" => $type_id,
            "phone" => $phone,
        );
        
        $data  = json_encode($data);    
        $headerArray = array("Content-type:application/json;charset='utf-8'","Accept:application/json");
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,FALSE);
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
        curl_setopt($curl,CURLOPT_HTTPHEADER,$headerArray);
        curl_setopt ($curl, CURLOPT_COOKIE , cookie('Set-Cookie'));
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        $output = curl_exec($curl);
        curl_close($curl);
        return $output;
    }
    
    /**
     * 获取考试题
     * @return type
     */
    public function getQuestion()
    {
        $form_id = input("get.formId");
        $phone = input("get.phone");
        $type = input("get.type");
        $returnData = Api::getToken();
        $return = (json_decode($returnData,true));
        $url = config('wx.url');
        $data = array(
            "_app_name" => "com.SAKX.FoodSafetyAdmin",
            "_Version" => "2.0",
            "g" => "ApiElearning",
            "m" => "Exam",
            "c" => "getQuestion",
            "_token" => $return['content']['access_token'],
            "form_id" => $form_id,
            "phone" => $phone,
            "type" => $type,
        );
        
        $data  = json_encode($data);    
        $headerArray = array("Content-type:application/json;charset='utf-8'","Accept:application/json");
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,FALSE);
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
        curl_setopt($curl,CURLOPT_HTTPHEADER,$headerArray);
        curl_setopt ($curl, CURLOPT_COOKIE , cookie('Set-Cookie'));
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        $output = curl_exec($curl);
        curl_close($curl);
        return $output;
    }
    
    /**
     * 提交答案
     * @return type
     */
    public function submitAnswers()
    {
        $form_id = input("get.formId");
        $phone = input("get.phone");
        $questionId = input("get.questionId");
        $studentId = input("get.studentId");
        $answer = input("get.answer");
        $answerId = input("get.answerId");
        $returnData = Api::getToken();
        $return = (json_decode($returnData,true));
        $url = config('wx.url');
        $data = array(
            "_app_name" => "com.SAKX.FoodSafetyAdmin",
            "_Version" => "2.0",
            "g" => "ApiElearning",
            "m" => "Exam",
            "c" => "addAnswers",
            "_token" => $return['content']['access_token'],
            "form_id" => $form_id,
            "phone" => $phone,
            "question_id" => $questionId,
            "answer" => $answer,
            "answer_id" => $answerId,
            "student_id" => $studentId,
        );
        
        $data  = json_encode($data);    
        $headerArray =array("Content-type:application/json;charset='utf-8'","Accept:application/json");
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,FALSE);
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
        curl_setopt($curl,CURLOPT_HTTPHEADER,$headerArray);
        curl_setopt ($curl, CURLOPT_COOKIE , cookie('Set-Cookie'));
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        $output = curl_exec($curl);
        curl_close($curl);
        return $output;
    }
    
    /**
     * 提交试卷
     * @return type
     */
    public function submitExam()
    {
        $studentId = input("get.studentId");
        $phone = input("get.phone");
        $returnData = Api::getToken();
        $return = (json_decode($returnData,true));
        $url = config('wx.url');
        $data = array(
            "_app_name" => "com.SAKX.FoodSafetyAdmin",
            "_Version" => "2.0",
            "g" => "ApiElearning",
            "m" => "Exam",
            "c" => "submitExam",
            "_token" => $return['content']['access_token'],
            "phone" => $phone,
            "student_id" => $studentId,
        );
        
        $data  = json_encode($data);    
        $headerArray =array("Content-type:application/json;charset='utf-8'","Accept:application/json");
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,FALSE);
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
        curl_setopt($curl,CURLOPT_HTTPHEADER,$headerArray);
        curl_setopt ($curl, CURLOPT_COOKIE , cookie('Set-Cookie'));
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        $output = curl_exec($curl);
        curl_close($curl);
        return $output;
    }
    
    /**
     * 获取课程栏目列表信息
     * @return type
     */
    public function getCourseList()
    {
        $id = input("get.id");
        $type_id = input("get.type_id");
        $returnData = Api::getToken();
        $return = (json_decode($returnData,true));
        $url = config('wx.url');
        $data = array(
            "_app_name" => "com.SAKX.FoodSafetyAdmin",
            // "_Version" => "2.0",
            "g" => "Api2.0",
            "m" => "Course",
            "c" => "public_getCategoryList",
            "_token" => $return['content']['access_token'],
            "type_id" => $type_id,
            "pid" => $id,
        );
        $output = curl_post($url, $data);
        return $output;
    }
    
    /**
     * 获取课程列表信息
     * @return type
     */
    public function courseList()
    {
        $cid = input("get.id");
        $is_need = input("get.is_need");
        $page = input("get.page");
        $row = input("get.row");
        $returnData = Api::getToken();
        $return = (json_decode($returnData,true));
        $url = config('wx.url');
        $data = array(
            "_app_name" => "com.SAKX.FoodSafetyAdmin",
            "_Version" => "2.0",
            "g" => "ApiElearning",
            "m" => "Course",
            "c" => "public_getCourseList",
            "_token" => $return['content']['access_token'],
            "category_id" => $cid,
            "page_index" => $page,
            "list_row" => $row,
            "is_need"=>$is_need,  //1必学课2选学课
        );
        $output = curl_post($url, $data);
        return $output;
    }
    
    /**
     * 获取课程明细列表信息
     * @return type
     */
    public function getCourseInfo()
    {
        $id = input("get.id");
        $returnData = Api::getToken();
        $return = (json_decode($returnData,true));
        $url = config('wx.url');;
        $data = array(
            "_app_name" => "com.SAKX.FoodSafetyAdmin",
            "_Version" => "2.0",
            "g" => "ApiElearning",
            "m" => "Course",
            "c" => "public_getCourseInfo",
            "_token" => $return['content']['access_token'],
            "course_id" => $id, 
        );
        $output = curl_post($url, $data);
        return $output;
    }
    
    /**
     * banner图展示
     * @return type
     */
    public function banner()
    {
        $returnData = Api::getToken();
        $return = (json_decode($returnData,true));
        $url = config('wx.url');
        $data = array(
            "_app_name" => "com.SAKX.FoodSafetyAdmin",
            "_Version" => "2.0",
            "g" => "ApiElearning",
            "m" => "Ad",
            "c" => "public_getAd",
            "_token" => $return['content']['access_token'],
            "flag" => "app_slideView_1",
        );
        $output = curl_post($url, $data);
        return $output;
    }
    
    /**
     * 学习记录信息
     * @return type
     */
    public function myLearning()
    {
        $page = input("get.page");
        $row = input("get.row");
        $phone = input("get.phone");
        $returnData = Api::getToken();
        $return = (json_decode($returnData,true));
        $url = config('wx.url');
        $data = array(
            "_app_name" => "com.SAKX.FoodSafetyAdmin",
            "_Version" => "2.0",
            "g" => "ApiElearning",
            "m" => "Course",
            "c" => "getMyCourseList",
            "_token" => $return['content']['access_token'],
            "page_index" => $page,
            "list_row" => $row,
            "phone" => $phone,
        );
        
        $data  = json_encode($data);    
        $headerArray =array("Content-type:application/json;charset='utf-8'","Accept:application/json");
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,FALSE);
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
        curl_setopt($curl,CURLOPT_HTTPHEADER,$headerArray);
        curl_setopt ($curl, CURLOPT_COOKIE , cookie('Set-Cookie'));
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        $output = curl_exec($curl);
        curl_close($curl);
        return $output;
    }
    
    /**
     * 我的收藏
     * @return type
     */
    public function myCollect()
    {
        $page = input("get.page");
        $row = input("get.row");
        $phone = input("get.phone");
        $returnData = Api::getToken();
        $return = (json_decode($returnData,true));
        $url = config('wx.url');
        $data = array(
            "_app_name" => "com.SAKX.FoodSafetyAdmin",
            "_Version" => "2.0",
            "g" => "ApiElearning",
            "m" => "Course",
            "c" => "getMyFavoriteCourseList",
            "_token" => $return['content']['access_token'],
            "page_index" => $page,
            "list_row" => $row,
            "phone" => $phone,
        );
        
        $data  = json_encode($data);    
        $headerArray =array("Content-type:application/json;charset='utf-8'","Accept:application/json");
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,FALSE);
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
        curl_setopt($curl,CURLOPT_HTTPHEADER,$headerArray);
        curl_setopt ($curl, CURLOPT_COOKIE , cookie('Set-Cookie'));
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        $output = curl_exec($curl);
        curl_close($curl);
        
        return $output;
    }
    
    /**
     * 我的证书
     * @return type
     */
    public function myCertificate()
    {
        $page = input("get.page");
        $row = input("get.row");
        $phone = input("get.phone");
        $returnData = Api::getToken();
        $return = (json_decode($returnData,true));
        $url = config('wx.url');
        $data = array(
            "_app_name" => "com.SAKX.FoodSafetyAdmin",
            "_Version" => "2.0",
            "g" => "ApiElearning",
            "m" => "Certificate",
            "c" => "getMyCertificateList",
            "_token" => $return['content']['access_token'],
            "page_index" => $page,
            "list_row" => $row,
            "phone" => $phone,
        );
        
        $data  = json_encode($data);    
        $headerArray = array("Content-type:application/json;charset='utf-8'","Accept:application/json");
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,FALSE);
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
        curl_setopt($curl,CURLOPT_HTTPHEADER,$headerArray);
        curl_setopt ($curl, CURLOPT_COOKIE , cookie('Set-Cookie'));
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        $output = curl_exec($curl);
        curl_close($curl);
        return $output;
    }
		
}